package cn.wolfcode.luowowo.common.util;


import java.util.Calendar;
import java.util.Date;

public class DateUtil {

    //计算时间秒差的方法 单位为秒
    public static Long getDifftime(Date date1, Date date2) {
        long difftime = Math.abs(date1.getTime() - date2.getTime());
        //讲毫秒转化为单位返回
        return difftime / 1000;
    }
    //获取一天中的最后一秒
    public static Date getEndDate(Date date){

        if (date == null){

            return null;
        }

        Calendar calendar = Calendar.getInstance();

        calendar.setTime(date);

        calendar.set(Calendar.HOUR,23);
        calendar.set(Calendar.MINUTE,59);
        calendar.set(Calendar.SECOND,59);

        return calendar.getTime();

    }


}
